<?php use_helper('Text') ?>
<?php use_helper('Slug') ?>

<?php if($sf_context->getConfiguration()->getEnvironment() === 'mod')
{
?>
<div align="right" style="font-size:18px">
	<a href="headers/modepanel">Panneau de modération</a>
</div>
<?php 
}
?>
<div class="title_section"> Les dernières nouvelles</div>
<div class="section">
<ul>
    <li class="inline" style="width:460px"></li>
      <li class="inline">Publiée le</li>
  </ul>
	
  <?php foreach ($news as $ObjNews):?>
  <ul class="elem_on_section">
    <li class="pointer_hand inline"  style="width:450px" onclick="display_elem('new_<?php echo $ObjNews["idnews"] ?>');swap_icon('new_<?php echo $ObjNews["idnews"] ?>','img_new_<?php echo $ObjNews["idnews"] ?>')"><?php echo image_tag("Icons/".$sf_context->getModuleName()."/plus.png", array("width" => 15,"height" => 15, "alt" => "pict", "id"=>"img_new_".$ObjNews["idnews"])) ?> <?php echo $ObjNews["titre"] ?></li>
      <li class="inline">
    		<?php echo date("d-m-Y h:i",strtotime($ObjNews["date_ajout"],time())) ?>
      </li>
      <li  id="new_<?php echo $ObjNews["idnews"] ?>" class="inline hidden"><?php echo sfOutputEscaper::unescape($ObjNews["texte"])?>
      </li>
  </ul>
  <?php endforeach; ?>
</div>
<div class="title_section">Les derniers articles publiés: </div>
<div class="section">
<ul class="titre_elem">
        	<li class="inline" style="width: 120px">
            	Disponible pour
            </li>
            <li class="inline" style="width: 400px">
            	Titre
            </li>
            <li class="inline" style="width: 110px">
            	Commentaires
            </li>
         </ul>
  <?php $i = 0;foreach($articles as $article):?>
  <ul class="elem_on_section">
    <li class="inline" style="width:70px;" >
      <?php 
	  for($j = 0; $j < count($article["Assoplatform"]) && $j < 3; $j++):?>
      <a href="<?php echo url_for("search/platform?id=".$article["Assoplatform"][$j]["Platform"]["id"]) ?>"><?php echo image_tag("Platform/".$article["Assoplatform"][$j]["Platform"]["picture"], array("width" => 20,"height" => 20, "alt"=> $article["Assoplatform"][$j]["Platform"]["real_name"],"title" => $article["Assoplatform"][$j]["Platform"]["real_name"])) ?></a>
      <?php endfor;?>
    </li>
    <li class="inline" style="width:20px;" title="<?php if(count($article["Assoplatform"]) > 2):?><?php foreach($article["Assoplatform"] as $assoPlat):?><?php echo $assoPlat["Platform"]["real_name"]?><?php endforeach;?><?php endif;?>">
      <?php if(count($article["Assoplatform"]) > 2):?>
      >>
      <?php endif;?>
    </li>
    <li class="inline" style="width:440px;"> <a class='block link_title' href="<?php echo url_for('@show_article_by_id?title='.sluggify($article["title"]).'&idarticles='.$article["idarticles"]); ?>"><?php echo truncate_text($article["title"], 50, "...")?></a>
    <span class='block tag'><?php echo image_tag("Icons/".$sf_context->getModuleName()."/bookmark.png", array("width" => 10,"height" => 10, "alt" => "pict")) ?>
      <?php foreach($article["Tags"] as $tag):?>
      <a href="search/tag?word=<?php echo $tag["tag"] ?>"><?php echo $tag["tag"] ?></a>
      <?php endforeach;?></span> </li>
    <li class="inline" style="width:110px;"><?php echo $nb_coms[$i] ?></li>
  </ul>
  </a>
  <?php $i++;endforeach;?>
</div>
<div class="title_section">Les derniers mots ajoutés dans le lexique: </div>
<div class="section">
 <ul class="titre_elem">
        	<li class="inline" style="width: 100px">
            	Auteur
            </li>
            <li class="inline" style="width: 150px">
            	Mot
            </li>
            <li class="inline" style="width: 400px">
            	Définition
            </li>
         </ul>
  <?php foreach($lexiques as $lexique):?> 
         <ul class="elem_on_section">
        	<li class="inline" style="width: 100px">
            	<a href="<?php echo url_for("compte/show?idprofil=".$lexique["SfGuardUserProfile"]["id"]) ?>" class="no_underline">
				<?php echo truncate_text($lexique["SfGuardUserProfile"]["User"]["username"], 40, "...")?></a>
            </li>
            <li class="inline" style="width: 150px">
            	<a class="link_title" href="<?php echo url_for('lexique/index?id='.$lexique["idlexique_mot"]); ?>"> <?php echo $lexique["mot"]?> </a>
            </li>
            <li class="inline" style="width: 400px">
            	<?php echo truncate_text($lexique["Lexiquedefinition"][0]["definition"], 70, "...")?>
            </li>

         </ul>

  <?php endforeach;?>
</div>
<div class="title_section">
	Dernières modifications des articles
</div>
<div class="section">
	<ul class="titre_elem">
        	<li class="inline" style="width: 100px">
            	Auteur
            </li>
            <li class="inline" style="width: 550px">
            	Article
            </li>
         </ul>
	<?php foreach($revisions as $revision):?>
    	<ul class="elem_on_section">
        	<li class="inline" style="width: 100px">
            	<a href="<?php echo url_for("compte/show?idprofil=".$revision["SfGuardUserProfile"]["id"]) ?>" class="no_underline"><?php echo truncate_text($revision["SfGuardUserProfile"]["User"]["username"], 50, "...")?></a>
            </li>
            <li class="inline" style="width: 550px">
            	<a class="link_title" href="<?php echo url_for('@show_article?title='.sluggify($revision["Assoplatform"]["Articles"]["title"]).'&idasso='.$revision["Assoplatform"]["idassoplatform"]); ?>"><?php echo truncate_text($revision["Assoplatform"]["Articles"]["title"], 80, "...")?></a>
            </li>
         </ul>
    <?php endforeach;?>
</div>
